<div>
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-body">
                <div style="float: right;margin-right: 17px;">
                    <a href="/play/showing-add" class="btn btn-success pull-right">新增</a>
                </div>
            </div>
            <div class="panel-body">
                <section id="no-more-tables">
                    <table class="table table-bordered table-striped table-condensed cf">
                        <thead class="cf">
                            <tr>
                                <td style="width: 100px;">序号</td>
                                <td style="width: 150px;">小组类别</td>
                                <td style="width: 100px;">场次</td>
                                <td style="width: 250px;">队伍A</td>
                                <td style="width: 250px;">队伍B</td>
                                <td style="width: 150px;">比赛时间</td>
                                <td style="width: 150px;">竞猜开放时间</td>
                                <td style="width: 150px;">竞猜截止时间</td>
                                <td style="width: 150px;">比赛结果</td>
                                <td style="width: 100px;">状态</td>
                                <td style="width: 150px;">操作</td>
                            </tr>
                        </thead>
                        <tbody>

                        <?php
                        $i = ($this->now - 1) * $this->size + 1;
                        foreach ($this->list_result as $_info) { ?>
                            <tr>
                                <input type="hidden" name="id[]" value="<?php echo $_info['id'] ?>">
                                <td data-title="id"><?php echo $i++; ?></td>
                                <td data-title="小组类别">
                                    <?php echo \Biz\Play\Showings::getTypeStr($_info['type']); ?>
                                </td>
                                <td data-title="场次">
                                    <?php echo $_info['play_number']; ?>
                                </td>
                                <td data-title="队伍A">
                                    <?php echo $this->player_list[$_info['player_a']]['player_name']??'--'; ?>
                                </td>
                                <td data-title="队伍B">
                                    <?php echo $this->player_list[$_info['player_b']]['player_name']??'--'; ?>
                                </td>
                                <td data-title="比赛时间">
                                    <?php echo $_info['start_time']; ?>
                                </td>
                                <td data-title="竞猜开放时间">
                                    <?php echo $_info['open_time']; ?>
                                </td>
                                <td data-title="竞猜截止时间">
                                    <?php echo $_info['stop_time']; ?>
                                </td>
                                <td data-title="比赛结果">
                                    <span style="display: inline-block;line-height: 25px;padding: 0 10px;border: 1px solid #e74c3c;background: #e74c3c;text-align: center;color: #fff;"><?php echo $_info['score_a'].' : '.$_info['score_b']; ?></span>
                                </td>
                                <td data-title="状态" <?php if($_info['status'] == \Biz\Play\Showings::STATUS_FINISH) echo 'style="color:red;"';?>>
                                    <?php echo \Biz\Play\Showings::getStatusStr($_info['status']); ?>
                                </td>
                                <td data-title="比赛时间">
                                    <?php if($_info['status'] != \Biz\Play\Showings::STATUS_FINISH){?>
                                        <a href="/play/showing-edit?id=<?php echo $_info['id'];?>">编辑</a>
                                        <a data-toggle="modal" href="#myModal" onclick="finalPut(this)" rel="<?php echo $_info['id'];?>" style="margin-left: 20px;">录入结果</a>
                                    <?php }?>
                                </td>
                            </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                    <?php echo $this->pageStr; ?>
                </section>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div style="background-color:#e9552e;padding:5px 0;text-align:center;color:white">
                <h5>录入比赛结果</h5>
            </div>
            <div class="modal-body">
                <div class="panel-body modal_content" id="ajax-content">

                </div>
            </div>
            <div class="modal-footer" style="text-align: center;">
                <button class="btn btn-success sure-save" type="button" id="subBtn" rel="0" style="background-color:#e9552e;border-color:#e9552e;" onclick="finalPutSubmit(this)">确认</button>
                <button class="btn btn-warning" type="button" data-dismiss="modal" class="close" style="margin-left: 50px;">取消</button>
            </div>
        </div>
    </div>
</div>

<script>
    function finalPut(el) {
        var id = $(el).attr('rel');
        var index = layer.msg('加载中，请稍等...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '0px', time:1000000});
        $.ajax({
            url  : '/play/showing-final',
            type : 'post',
            data : {
                type:'show',
                id:id
            },
            dataType : 'json',
            beforeSend:function () {
                $("#ajax-content").html('');
            },
            success : function (msg) {
                if (msg.code === 200) {
                    layer.close(index);
                    $("#ajax-content").html(msg.result.htmlcode);
                } else{
                    layer.close(index);
                    layer.alert(msg.message);
                }
            }
        });
    }
    function finalPutSubmit(el) {
        var id = $('#play_id').val();
        if(!id){
            layer.msg('数据错误');
            return false;
        }
        layer.confirm('结果一旦确认不可修改，确定输入的结果正确？',function () {
            var index = layer.msg('加载中，请稍等...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '0px', time:1000000});
            $.ajax({
                url  : '/play/showing-final',
                type : 'post',
                data : $("#subForm").serialize(),
                dataType : 'json',
                success : function (msg) {
                    layer.close(index);
                    layer.alert(msg.message);
                    if (msg.code === 200) {
                        window.location.reload();
                    }
                }
            });
        });
    }
</script>